﻿package mortal.game.resource
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class ErrorCodeConfig extends Object
    {
        private var _map:Dictionary;
        private static var _instance:ErrorCodeConfig;

        public function ErrorCodeConfig()
        {
            this._map = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TErrorCode = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TErrorCode();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._map[_loc_2.errorCode] = _loc_2;
            }
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_error_code.json");
            this.write(_loc_1);
            return;
        }// end function

        public function getInfoByCode(param1:int) : TErrorCode
        {
            return this._map[param1];
        }// end function

        public function getErrorStringByCode(param1:int) : String
        {
            var _loc_2:* = this._map[param1];
            if (_loc_2)
            {
                return _loc_2.errorStr;
            }
            return "";
        }// end function

        public static function get instance() : ErrorCodeConfig
        {
            if (_instance == null)
            {
                _instance = new ErrorCodeConfig;
            }
            return _instance;
        }// end function

    }
}
